package org.openmrs;

public class Attribute extends BaseOpenmrsMetadata implements java.io.Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3510061832592863724L;
	
	private String attributeName;
	
	private String ownerType;
	
	private String dataType;
	
	public String getOwnerType() {
		return ownerType;
	}
	
	public void setOwnerType(String ownerType) {
		this.ownerType = ownerType;
	}
	
	@Override
	public Integer getId() {
		throw new UnsupportedOperationException();
	}
	
	@Override
	public void setId(Integer id) {
		throw new UnsupportedOperationException();
	}
	
	public String getAttributeName() {
		return attributeName;
	}
	
	public void setAttributeName(String attributeName) {
		this.attributeName = attributeName;
	}
	
	public String getDataType() {
		return dataType;
	}
	
	public void setDataType(String dataType) {
		this.dataType = dataType;
	}
	
	@Override
	public boolean equals(Object object) {
		if (object instanceof Attribute) {
			Attribute attribute = (Attribute) object;
			if (this.getAttributeName() != null && attribute.getAttributeName() != null) {
				if (this.getAttributeName().equals(attribute.getAttributeName())) {
					return true;
				}
			}
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		int hashCode = 0;
		if (this.getAttributeName() == null && this.getDataType() == null) {
			return super.hashCode();
		}
		
		if (this.getAttributeName() != null) {
			hashCode = this.getAttributeName().hashCode();
		}
		
		if (this.getDataType() != null) {
			hashCode += this.getDataType().hashCode();
		}
		
		if (this.getOwnerType() != null) {
			hashCode += this.getOwnerType().hashCode();
		}
		
		return hashCode;
	}
	
}
